<%--
  Created by IntelliJ IDEA.
  User: 86181
  Date: 2022/11/25
  Time: 11:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登记审核模态框</title>
</head>
<body>
        <form id="produktionsregistrierungDispatchrexamineshowmodalfrom">
    <div class="modal-header">
        <input type="submit" class="btn btn-default" value="复核通过">
        <button class="close" data-dismiss="modal">退出</button>
    </div>
     <input type="text" name="parentId" id="prouktionid">
    <div class="modal-body" align="center">
        <div class="row">
            <div><strong><h2>生产登记单</h2></strong></div>
        </div>
        <br>
        <div class="row">
            <div class="col-md-6">
                <table>
                    <tr>
                        <td>派工单编号:</td>
                        <td><input type="text" id="produktondispatchmanufactureIdshowall" readonly style="outline: none;border: none;height: 40px"></td>
                    </tr>
                    <tr>
                        <td>负责人:</td>
                        <td><input type="text" readonly name="procedureResponsiblePerson" value="${username}" id="produktonprocedureResponsiblePersonshowall"  style="outline: none;border: none;height: 40px;background-color: gainsboro"></td>
                    </tr>
                    <tr>
                        <td>已用工时:</td>
                        <td><input type="text" id="yjHourAmountshowall"   readonly style="outline: none;border: none;height: 40px;"></td>
                    </tr>
                </table>
            </div>
            <div class="col-md-6">
                <table>
                    <tr>
                        <td>工序名称:</td>
                        <td><input type="text" name="procedureName" readonly id="priduktionproductNameshowall" style="outline: none;border: none;height: 40px"></td>
                    </tr>
                    <tr>
                        <td>设计工时:</td>
                        <td><input type="text" readonly id="labourHourlabourHourAmountshowall" style="outline: none;border: none;height: 40px;"></td>
                    </tr>
                    <tr>
                        <td>本次工时:</td>
                        <td><input type="text" readonly  name="labourHourAmount" id="producktinrealLabourHourAmountshowall"   style="outline: none;border: none;height: 40px;background-color: gainsboro"></td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <br>
    <div style="height:40%">
        <table id="produktionsregistrierungDispatchmodaltabhsowall">

        </table>
    </div>
    <br>
    <div class="row">
        <div class="col-md-6">
            <table>
                <tr>
                    <td>复核人:</td>
                    <td><input type="text" name="checker" value="${username}" id="checkershowall" style="outline: none;border: none;height: 40px;background-color: gainsboro"></td>
                </tr>
            </table>
        </div>
        <div class="col-md-6">
            <table>
                <tr>
                    <td>
                        复核时间:</td>
                    <td><input type="text" name="checkTime" id="checkTimeshowall" style="outline: none;border: none;height: 40px;"></td>
                </tr>
            </table>
        </div>
    </div>
</form>

        <script>
            //加载表格数据
            $(function () {
                var id='${param.id}'
                $("#prouktionid").val(id)
                var dispatchmanufactureIdshow='${param.dispatchmanufactureIdshow}'
                $("#produktionsregistrierungDispatchmodaltabhsowall").bootstrapTable({
                    contentType: "application/x-www-form-urlencoded", //如果用tomcat就要写这个
                    striped: true,//是否显示隔行变色
                    cache: false,//是否缓存
                    pagination: false,//是否显示分页
                    sortable: false,//是否显示排序
                    clickToSelect: true,//是否启用点击选中行
                    uniqueId:"id",//每一行的唯一标识，一般为主键列,
                    showRefresh: true,//是否显示刷新按钮
                    columns:[
                        {
                            field:"",
                            title:"序号",
                            formatter:function (value,row,index) {
                                return Number(index)+1;
                            }
                        },
                        {
                            field:"productName",
                            title:"物料名称",
                        },
                        {
                            field:"productId",
                            title:"物料编号",
                        },
                        {
                            field:"amount",
                            title:"设计数量",
                        },
                        {
                            field:"realAmount",
                            title:"已经使用数量",
                        },
                        {
                            field:"isnum",
                            title:"本次数量",
                        }
                    ]
                })
                //查询数据
                $.post("queryByMProcedureModule.action",{"id":id},function (data) {
                    console.log(data)
                    //赋值
                    //派工单编号
                    $("#produktondispatchmanufactureIdshowall").val(dispatchmanufactureIdshow)
                    //已用工时
                    $("#yjHourAmountshowall").val(0)
                    //负责人
                    //工序名称
                    $("#priduktionproductNameshowall").val(data.procedureName)
                    //设置工时
                    $("#labourHourlabourHourAmountshowall").val(data.labourHourAmount)

                    //本次工时
                    $("#producktinrealLabourHourAmountshowall").val(data.labourHourAmount)
                    //登记时间
                    //点击获取当前时间
                    $.get("queryCellByDate.action",function (data) {
                        $("#checkTimeshowall").val(data.datetime)
                    },"json")
                    //添加数据
                    var arr=[]
                    var datas=data.procedureModules;
                    for(var i=0;i<datas.length;i++){
                        arr.push(datas[i])
                    }
                    //加载表格数据
                    $("#produktionsregistrierungDispatchmodaltabhsowall").bootstrapTable("append",arr)
                },"json")
            })
            //复核
           $("#produktionsregistrierungDispatchrexamineshowmodalfrom").validate({
               submitHandler:function () {
                   //获取表单数据
                   var arr=$("#produktionsregistrierungDispatchrexamineshowmodalfrom").serializeArray();
                   var mProceduring={};
                   $(arr).each(function (index,item) {
                        mProceduring[item.name]=item.value;
                   })
                   //获取表格数据
                  var arrs=$("#produktionsregistrierungDispatchmodaltabhsowall").bootstrapTable("getData")
                   mProceduring["mproceduremodules"]=arrs;
                   console.log(mProceduring)

                   $.ajax({
                       url:"updateMproceduring.action",
                       data:JSON.stringify(mProceduring),
                       contentType:"application/json",
                       type:"post",
                       dataType:"json",
                       success:function (data) {
                            alert(data.msg)
                           //关闭模态框
                           $("#produktionsregistrierungDispatchrexamineshowmodal").modal("hide")
                           aloshow()
                       }
                   })

               }
           })
        </script>
</body>
</html>
